package com.kk.dateAndTime;

import cn.hutool.core.date.*;

/**
 * the type of advance
 *
 * <p>
 * .
 *
 * @author 王志强
 * @date 2022-03-21
 */
public class DateUtilClient {
    public static void main(String[] args) {

        DateTime date = DateUtil.date();
//获得年月日
        int year = DateUtil.year(date);
        int month = DateUtil.month(date);
        Month month1 = DateUtil.monthEnum(date);
        int dayOfMonth = DateUtil.dayOfMonth(date);
        int dayOfWeek = DateUtil.dayOfWeek(date);
        int dayOfYear = DateUtil.dayOfYear(date);
//格式化时间
        String format = DateUtil.format(date, "yyyy*MM*dd");


//设置偏移量
        DateTime offset = DateUtil.offset(date, DateField.DAY_OF_MONTH, 3);
        DateTime dateTime = DateUtil.offsetHour(date, -12);

//计算时间差
        String dateStr1 = "2017-03-01 22:33:23";
        DateTime parse = DateUtil.parse(dateStr1);
        String dateStr2 = "2018-03-02 23:34:24";
        DateTime parse1 = DateUtil.parse(dateStr2);
//Level.second表示精确到秒
        String between = DateUtil.formatBetween(parse, parse1, BetweenFormatter.Level.SECOND);


//星座和生肖
        String zodiac = DateUtil.getZodiac(11, 21);
        String chineseZodiac = DateUtil.getChineseZodiac(1997);

//从5.4.1开始，Hutool支持天干地支的获取
        ChineseDate chineseDate = new ChineseDate(DateUtil.date());
        String cyclicalYMD = chineseDate.getCyclicalYMD();

    }
}
